window.onload = function(){
    let username = document.querySelector('#username');
    let password = document.querySelector('#password');
    // 当有cookie数据时 获得cookie字符串
    // 当没有cookie时 获得空字符串

    if(document.cookie){
      let cookies = document.cookie.split('; ');

      cookies.forEach(el=>{
        let [key,value] = el.split('=');

        switch(key){
          case 'username':
            username.value = value;
            savepass.setAttribute('checked',true);
            break;
          case 'password':
            password.value = value;
            break;
        }
      });
    }
  };